package com.monkeyk.os.util;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 返回数据
 * 
 * @author fhh
 * @email fhh@qq.com
 * @date 2017年10月27日 下午9:59:27
 */
public class AJBResponse extends LinkedHashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public AJBResponse() {
		put("code", AJBRspCon.SUCCESS.getCode());
		put("msg", AJBRspCon.SUCCESS.getMsg());
	}
	
	public static AJBResponse error() {
		return error(AJBRspCon.ERROR.getCode(), AJBRspCon.ERROR.getMsg());
	}
	
	public static AJBResponse error(String msg) {
		return error(AJBRspCon.ERROR.getCode(), msg);
	}
	
	public static AJBResponse error(int code, String msg) {
		AJBResponse r = new AJBResponse();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}
	public static AJBResponse successData(Object datas) {
		AJBResponse r = new AJBResponse();
		r.put("datas",datas);
		return r;
	}
	public static AJBResponse success(String msg) {
		AJBResponse r = new AJBResponse();
		r.put("msg", msg);
		return r;
	}
	public static AJBResponse successData(String msg,Object datas) {
		AJBResponse r = new AJBResponse();
		r.put("msg", msg);
		r.put("datas",datas);
		return r;
	}
	
	public static AJBResponse info(int code,String msg) {
		AJBResponse r = new AJBResponse();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}
	
	public static AJBResponse info(int code,String msg,Object datas) {
		AJBResponse r = new AJBResponse();
		r.put("msg", msg);
		r.put("datas",datas);
		return r;
	}
	
	public static AJBResponse successData(String code,String msg,Object datas) {
		AJBResponse r = new AJBResponse();
		r.put("code", code);
		r.put("msg", msg);
		r.put("datas",datas);
		return r;
	}
	
	public static AJBResponse success(Map<String, Object> map) {
		AJBResponse r = new AJBResponse();
		r.putAll(map);
		return r;
	}
	
	
	
	public static AJBResponse success() {
		return new AJBResponse();
	}

	public AJBResponse put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
